function sumFibs(num) {
    let fib = [1, 1];
    let a = fib[0], b = fib[1];
    while (a + b <= num) {
        let c = a + b;
        a = b;
        b = c;
        if (c % 2 === 1)
            fib.push(c);
    }
    return fib.reduce(function (sum, val) {
        return sum + val;
    }, 0);
}

console.log(sumFibs(4));
